import { createHospitalApi } from '@/api/pcs/pcsHospital'
import AekForm from '@/components/AekForm'
import AekModal, { PromiseThen } from '@/components/AekModal'
import { requestWithTry } from '@/utils/request'

const EditModal = () => {
  const [form] = AekForm.useForm()

  /** @type {import("@/components/AekForm").FormDataProps[]} */
  const formData = [
    {
      field: 'name',
      label: '名称',
      formItemProps: {
        rules: [{ required: true }],
      },
      component: { name: 'Input' },
    },
  ]

  const onOk = async () => {
    const values = await form.validateFields()
    const params = {
      ...values,
    }
    await requestWithTry(createHospitalApi, params)
  }
  return (
    <AekModal title='新增' width={500} onOk={onOk}>
      <AekForm form={form} formData={formData} />
    </AekModal>
  )
}

EditModal.PromiseThen = PromiseThen

export default EditModal
